<!DOCTYPE html>
<html lang="en">

<head>
    <title>html5</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>


<body>
    <script>
        var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
        db.transaction(function (tx) {
            tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)');
        });

        db.transaction(function (tx) {
            tx.executeSql('INSERT INTO LOGS (id, log) VALUES (1, "html")');
            tx.executeSql('INSERT INTO LOGS (id, log) VALUES (2, "html5")');
        });
        db.transaction(function (tx) {
            tx.executeSql('SELECT * FROM LOGS', [], function (tx, results) {
                var len = results.rows.length, i;
                msg = "<p>查询记录条数: " + len + "</p>";
                document.querySelector('#status').innerHTML += msg;

                for (i = 0; i < len; i++) {
                    alert(results.rows.item(i).log);
                }

            }, null);
        });
    </script>
</body>

</html>